<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8" autoFlush="true"%>
<%@include file="/common/taglib.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page import="java.util.*"%>
<html>
<x:multiLanguage>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href='<s:url value="/resource/css/main.css" />' type="text/css">
<link href="../css/dialog.css" rel="stylesheet" type="text/css" />
<script src="common/fck_dialog_common.js" type="text/javascript"></script>
<script src='<s:url value="/dwr/engine.js"/>'></script>
<script src='<s:url value="/dwr/util.js"/>'></script>
<script src='<s:url value="/dwr/interface/FormHelper.js"/>'></script>
<script src='<s:url value="/dwr/interface/Sequence.js"/>'></script>
<script language="JavaScript" src="dialog.js"></script>
<script language="JavaScript" src="script.js"></script>
<script language="JavaScript" src="sequence.js"></script>
<SCRIPT language=JavaScript>
var dialog	= window.parent ;
var oEditor = dialog.InnerDialogLoaded() ;

// Gets the document DOM
var oDOM = oEditor.FCK.EditorDocument ;

var oActiveEl = dialog.Selection.GetSelectedElement() ;

// 选项卡点击事件
function cardClick(cardID){
	var obj;
	for (var i=1;i < 8;i++){
		obj=document.all("card"+i);
		obj.style.backgroundColor="#3A6EA5";
		obj.style.color="#FFFFFF";
	}
	obj=document.all("card"+cardID);
	obj.style.backgroundColor="#FFFFFF";
	obj.style.color="#3A6EA5";

	for (var i=1;i < 8;i++){
		obj=document.all("content"+i);
		obj.style.display="none";
	}
	obj=document.all("content"+cardID);
	obj.style.display="";
	resize();
}

//初始值
function InitDocument(){
	var editMode;
	oEditor.FCKLanguageManager.TranslatePage(document) ;
	if ( oActiveEl && (oActiveEl.tagName == 'INPUT'))
	{
		if(oActiveEl.name!=null){
			temp.name.value = HTMLDencode(oActiveEl.name);
		}

		if(oActiveEl.refreshOnChanged!=null){
			temp.refreshOnChanged.checked = oActiveEl.refreshOnChanged == "true";
		}else{
			temp.refreshOnChanged.checked = false;
		}

		if(oActiveEl.calculateOnRefresh!=null){
			temp.calculateOnRefresh.checked = oActiveEl.calculateOnRefresh == "true";
		}else{
			temp.calculateOnRefresh.checked = false;
		}

		if(oActiveEl.mobile!=null){
			temp.mobile.checked = oActiveEl.mobile == "true";
		}else{
			temp.mobile.checked = false;
		}
	
		if(oActiveEl.discript!=null){
			temp.discript.value = HTMLDencode(oActiveEl.discript);
		}

		if(oActiveEl.valueScript!=null){
			temp.valueScript.value = HTMLDencode(oActiveEl.valueScript);
		}

		if(oActiveEl.optionsScript!=null){
			temp.optionsScript.value = HTMLDencode(oActiveEl.optionsScript);
		}

		if(oActiveEl.validateRule!=null){
			temp.validateRule.value = HTMLDencode(oActiveEl.validateRule);
		}

		if(oActiveEl.hiddenScript!=null){
			temp.hiddenScript.value = HTMLDencode(oActiveEl.hiddenScript);
		}

		if(oActiveEl.hiddenValue!=null){
			temp.hiddenValue.value = HTMLDencode(oActiveEl.hiddenValue);
		}

		if(oActiveEl.hiddenPrintScript!=null){
			temp.hiddenPrintScript.value = HTMLDencode(oActiveEl.hiddenPrintScript);
		}

		if(oActiveEl.printHiddenValue!=null){
			temp.printHiddenValue.value = HTMLDencode(oActiveEl.printHiddenValue);
		}

		if(oActiveEl.filtercondition!=null){
			temp.filtercondition.value =HTMLDencode(oActiveEl.filtercondition);
		}

		if(oActiveEl.readonlyScript!=null){
			temp.readonlyScript.value = HTMLDencode(oActiveEl.readonlyScript);
		}
		//temp.textType.value = HTMLDencode(oActiveEl.textType);
		
		if(oActiveEl.layout!=null){
			temp.layout.value = HTMLDencode(oActiveEl.layout);
		}

		if(oActiveEl.editMode!=null){
			editMode=HTMLDencode(oActiveEl.editMode);
		}

		if(oActiveEl.processDescription!=null){
			var items=HTMLDencode(oActiveEl.processDescription);
		    parseRelStr(items);
		}

	    
		if(oActiveEl.textType==null){
			oActiveEl.textType='text';
		}
		temp.textType.value = HTMLDencode(oActiveEl.textType);

		if(oActiveEl.validateLibs!=null){
			var libstr=HTMLDencode(oActiveEl.validateLibs);
			var lib=libstr.split(';');
			var validateLibs=document.getElementsByName('validateLibs');
		    for(var i=0; i< lib.length; i++){
		       for(var j=0; j< validateLibs.length; j++){
	 			if(validateLibs[j].value==lib[i]){
	 				validateLibs[j].checked=true;
	 					}
	 				}
	 			}
		}
	}
	else
		oActiveEl = null ;
	dialog.SetOkButton( true ) ;
	dialog.SetAutoSize( true ) ;
	SelectField( 'name' ) ;
	initForm();
	modeChange(editMode);
	resize();
	window.top.toThisHelpPage("application_module_form_info_advance_checkbox");
}

//OK方法
function Ok()
{
	if(ev_check()){
	oEditor.FCKUndo.SaveUndoStep() ;
	var className="cn.myapps.core.dynaform.form.ejb.CheckboxField";
	// modify by kent
	var id="";	
	var editMode=document.getElementsByName("editMode");  
    for(var i=0;i<editMode.length;i++){
		  if(editMode[i].checked){
			   ed += editMode[i].value;
	      }
	    } 
	var validateLibs=document.getElementsByName('validateLibs');
	var libs='';
	for(var i=0; i< validateLibs.length; i++){
 		if(validateLibs[i].checked){
 			libs+=validateLibs[i].value+";";
 		}
 	}
 	libs=libs.substring(0,libs.length-1);

	oActiveEl = CreateNamedElement( oEditor, oActiveEl, 'INPUT', {
									classname: className,
									id: id,
									type:"checkbox",
									name: GetE('name').value/* ,
									discript:HTMLEncode(temp.discript.value),
									refreshOnChanged:HTMLEncode(temp.refreshOnChanged.checked+""),
									calculateOnRefresh:HTMLEncode(temp.calculateOnRefresh.checked+""),
									mobile: HTMLEncode(temp.mobile.checked+""),
									valueScript:HTMLEncode(temp.valueScript.value),
									optionsScript:HTMLEncode(temp.optionsScript.value),
									validateRule:HTMLEncode(temp.validateRule.value),
									hiddenScript:HTMLEncode(temp.hiddenScript.value),
									hiddenValue:HTMLEncode(temp.hiddenValue.value),
									hiddenPrintScript:HTMLEncode(temp.hiddenPrintScript.value),
									printHiddenValue:HTMLEncode(temp.printHiddenValue.value),
									layout:HTMLEncode(temp.layout.value),
									textType:HTMLEncode(temp.textType.value),
									fieldtype:"VALUE_TYPE_TEXT",
									processDescription:HTMLEncode( createRelStr()),  
									filtercondition:HTMLEncode(temp.filtercondition.value), 
									readonlyScript:HTMLEncode(temp.readonlyScript.value),
									validateLibs:HTMLEncode(libs),
									editMode:HTMLEncode(ed),
									processDescription:HTMLEncode( createRelStr()) */
									} 
								   ) ;	

	return true ;
	}
}

//检查内容是否完成正确
function ev_check(){
   if(temp.name.value==''){
 	  alert("{*[page.name.notexist]*}");
	  return false;
   }
   return !checkStartChar(temp.name.value);
}

function checkStartChar(value){
	return IsDigit(value,"{*[page.name.startingit]*}");
}
</script>

</HEAD>

<BODY bgcolor=menu onload="InitDocument()">

<form name="temp">
		<table border=0 cellpadding=3 cellspacing=0 width="520px">
			<tr align=center>
				<td class="card" onclick="cardClick(1)" id="card1">{*[Basic]*}</td>
				<td width=2></td>
				<td class="card" onclick="cardClick(2)" id="card2">{*[Value_Script]*}</td>
				<td width=2></td>
				<td class="card" onclick="cardClick(3)" id="card3">{*[Option_Script]*}</td>
				<td width=2></td>
				<td class="card" onclick="cardClick(4)" id="card4">{*[Validate_Script]*}</td>
				<td width=2></td>
				<td class="card" onclick="cardClick(5)" id="card5">{*[Hidden_Script]*}</td>
				<td width=2></td>
				<td class="card" onclick="cardClick(6)" id="card6">{*[Hidden_Print_Script]*}</td>
				<td width=2></td>
				<td class="card" onclick="cardClick(7)" id="card7">{*[ReadOnly_Script]*}</td>
				<td width=2></td>
				<input style="display: none" type="checkbox" checked="checked"/>
			</tr>
			<tr>
				<td align=center valign=middle colspan="13">
				<!--***************************** Content 1 ***************************************-->
				<table border=1 cellpadding=3 cellspacing=1 class="content"
					id="content1">
					<tr>
						<td class="commFont commLabel">{*[Name]*}:</td>
						<td colspan="3"><input type=text width='98%' name="name" onchange="checkStartChar(this.value);"></td>
					</tr>
					<tr>
						<td class="commFont commLabel">{*[Layout]*}:</td>
						<td><select name="layout">
							<option value="horizontal" selected>{*[Horizontal]*}</option>
							<option value="vertical">{*[Vertical]*}</option></td>

						<td class="commFont commLabel">{*[TextType]*}:</td>
						<td><select name="textType">
							<option value="text" selected>{*[Common]*}</option>
							<option value="readonly">{*[Readonly]*}</option>
						</select></td>
					</tr>
					<tr>
						<td colspan="4" align="center">
							<input type=checkbox name="refreshOnChanged" value="true">{*[Refresh]*}&nbsp;
							<input type=checkbox name="calculateOnRefresh" value="true">{*[Recalculate]*}&nbsp;
							<input type=checkbox name="mobile" value="true" checked />{*[Mobile]*}&nbsp;
						</td>
					</tr>
					<tr>
						<td class="commFont commLabel">{*[Description]*}:</td>
						<td colspan="3"><textarea name="discript" style="width:100%" rows="7"></textarea></td>
					</tr>
				</table>

				<!--***************************** Content 2 ***************************************-->
				<table border=1 cellpadding=3 cellspacing=1 class="content"
					id="content2">
					<tr>
						<%@include file="commondialog.jsp"%>
					</tr>
				</table>
				<!--***************************** Content 3 ***************************************-->
				<table border=1 cellpadding=3 cellspacing=1 class="content"
					id="content3">
					<tr>
						<td><textarea name="optionsScript" style="width:96%" rows="10"></textarea>
						<button style="border:0px;cursor: pointer;" onclick="openIscriptEditor('optionsScript','{*[Script]*}{*[Editor]*}','{*[Option_Script]*}','name','{*[Save]*}{*[Success]*}');"><img alt="Open with IscriptEditor" src="<s:url value='/resource/image/editor.png' />"/></button>
						</td>
					</tr>
				</table>
				<!--***************************** Content 4 ***************************************-->
				<table border=1 cellpadding=3 cellspacing=1 class="content"
					id="content4">
					<tr>
						<td width="25%">
						<table>
						<tr>
								<td><input type="checkbox" name="validateLibs"
									value="" />test</td>
							</tr>
						</table>
						</td>
						<td width="75%"><textarea name="validateRule" style="width:95%"
							rows="10"></textarea>
							<button style="border:0px;cursor: pointer;" onclick="openIscriptEditor('validateRule','{*[Script]*}{*[Editor]*}','{*[Validate_Script]*}','name','{*[Save]*}{*[Success]*}');"><img alt="Open with IscriptEditor" src="<s:url value='/resource/image/editor.png' />"/></button>
							</td>
					</tr>
				</table>
				<!--***************************** Content 5 ***************************************-->
				<table border=1 cellpadding=3 cellspacing=1 class="content"
					id="content5">
					<tr>
						<td><textarea name="hiddenScript" style="width:96%" rows="10"></textarea>
						<button style="border:0px;cursor: pointer;" onclick="openIscriptEditor('hiddenScript','{*[Script]*}{*[Editor]*}','{*[Hidden_Script]*}','name','{*[Save]*}{*[Success]*}');"><img alt="Open with IscriptEditor" src="<s:url value='/resource/image/editor.png' />"/></button>
						</td>
					</tr>
					<tr>
						<td>{*[hiddenValue]*}：<input id="hiddenValue" type="text" name="hiddenValue" /></td>
					</tr>
				</table>
				<!--***************************** Content 6 ***************************************-->
				<table border=1 cellpadding=3 cellspacing=1 class="content"
					id="content6">
					<tr>
						<td><textarea name="hiddenPrintScript" style="width:95%" rows="10"></textarea>
						<button style="border:0px;cursor: pointer;" onclick="openIscriptEditor('hiddenPrintScript','{*[Script]*}{*[Editor]*}','{*[Hidden_Print_Script]*}','name','{*[Save]*}{*[Success]*}');"><img alt="Open with IscriptEditor" src="<s:url value='/resource/image/editor.png' />"/></button>
						</td>
					</tr>
					<tr>
						<td>{*[Print]*}{*[hiddenValue]*}：<input  type="text" name="printHiddenValue" /></td>
					</tr>
				</table>
				<!--***************************** Content 7 ***************************************-->
				<table border=1 cellpadding=3 cellspacing=1 class="content"
					id="content7">
					<tr>
						<td><textarea name="readonlyScript" style="width:96%" rows="10"></textarea>
						<button style="border:0px;cursor: pointer;" onclick="openIscriptEditor('readonlyScript','{*[Script]*}{*[Editor]*}','{*[ReadOnly_Script]*}','name','{*[Save]*}{*[Success]*}');"><img alt="Open with IscriptEditor" src="<s:url value='/resource/image/editor.png' />"/></button>
						</td>
					</tr>
				</table>
				</td>
			</tr>
		</table>
</form>

<script language=javascript>
cardClick(1);
</script>

</BODY>
</x:multiLanguage>
</HTML>
